/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * InventoryFrame.java
 *
 * Created on Feb 4, 2011, 2:34:46 PM
 */

package gbbmgmt;

import javax.swing.table.*;
import org.jdesktop.application.Action;

/**
 *
 * @author dchapman
 */
public class InventoryFrame extends javax.swing.JFrame {

    /** Creates new form InventoryFrame */
    public InventoryFrame() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jTableInventory = new javax.swing.JTable();
        jButtonRefresh = new javax.swing.JButton();
        jButtonExit = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setName("Form"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        jTableInventory.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Beer Name:", "# 1/2 BBL Kegs:", "# 1/4 BBL Kegs:", "# 1/6 BBL Kegs:", "# 22 Oz. Bottles:", "# 12 Oz. Bottles:", "# 750 mL Bottles:"
            }
        ));
        jTableInventory.setName("jTableInventory"); // NOI18N
        jScrollPane1.setViewportView(jTableInventory);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(gbbmgmt.GBBMGMTApp.class).getContext().getResourceMap(InventoryFrame.class);
        jTableInventory.getColumnModel().getColumn(0).setHeaderValue(resourceMap.getString("jTableInventory.columnModel.title0")); // NOI18N
        jTableInventory.getColumnModel().getColumn(1).setHeaderValue(resourceMap.getString("jTableInventory.columnModel.title1")); // NOI18N
        jTableInventory.getColumnModel().getColumn(2).setHeaderValue(resourceMap.getString("jTableInventory.columnModel.title2")); // NOI18N
        jTableInventory.getColumnModel().getColumn(3).setHeaderValue(resourceMap.getString("jTableInventory.columnModel.title3")); // NOI18N
        jTableInventory.getColumnModel().getColumn(4).setHeaderValue(resourceMap.getString("jTableInventory.columnModel.title4")); // NOI18N
        jTableInventory.getColumnModel().getColumn(5).setHeaderValue(resourceMap.getString("jTableInventory.columnModel.title5")); // NOI18N
        jTableInventory.getColumnModel().getColumn(6).setHeaderValue(resourceMap.getString("jTableInventory.columnModel.title6")); // NOI18N

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(gbbmgmt.GBBMGMTApp.class).getContext().getActionMap(InventoryFrame.class, this);
        jButtonRefresh.setAction(actionMap.get("InvRefresh")); // NOI18N
        jButtonRefresh.setText(resourceMap.getString("jButtonRefresh.text")); // NOI18N
        jButtonRefresh.setName("jButtonRefresh"); // NOI18N

        jButtonExit.setAction(actionMap.get("InvExit")); // NOI18N
        jButtonExit.setText(resourceMap.getString("jButtonExit.text")); // NOI18N
        jButtonExit.setName("jButtonExit"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 732, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jButtonRefresh)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 610, Short.MAX_VALUE)
                        .addComponent(jButtonExit)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 371, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonRefresh)
                    .addComponent(jButtonExit))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new InventoryFrame().setVisible(true);
            }
        });
    }

    public void AddInvRow(String Name, String Half, String Qtr,
            String Six, String TT, String TW, String SF){
        DefaultTableModel tabelModel = (DefaultTableModel)jTableInventory.getModel();
        tabelModel.addRow(new Object[]{Name,Half,Qtr,Six,TT,TW,SF});
    }

    @Action
    public void InvExit() {
        dispose();
    }

    @Action
    public void InvRefresh() {
        DBA.openDBCon();
        DBA.PerformInventoryQuery();
        DBA.closeDBCon();
        dispose();
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonExit;
    private javax.swing.JButton jButtonRefresh;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTableInventory;
    // End of variables declaration//GEN-END:variables

}
